import java.util.Arrays;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 28318
 * Date: 2025-11-06
 * Time: 18:10
 */
public class Test {

    public static void main(String[] args) {
        String[] str = new String[]{
                "abcabc",
                "aabbbbb",
                "pwwkew",
                "d",
                "",
                " el.rg[;. erf 56r f65ae rg.p[; df",
                "abcabcbb",
                "aab",
                "dvdf"
        };
        for (String s : str) {
            System.out.println(lengthOfLongestSubstring(s));
        }
        String strN = new String();
        String strs = "hello";
//        StringBuffer strB = "hello";
        StringBuffer sB = new StringBuffer("hello");
    }

    public static int lengthOfLongestSubstring(String s) {
        int ret = 0;
        int check = 1;
        for (int p = 0, start = p; p < s.length(); p++) {
            if (stringToFind(s, start, p, s.charAt(p))){
                if (check > ret){
                    ret = check;
                }
                start = p;
                check = 1;
            }else {
                check = p - start + 1;
            }
            if (p == s.length() - 1){
                if (p - start + 1 > ret){
                    ret = p - start + 1;
                }
            }
        }
        return ret;
    }

    //true表示找到,false表示没找到
    public static boolean stringToFind(String s, int start, int end, char target){
        for (int i = start; i < end; i++) {
            if (s.charAt(i) == target){
                return true;
            }
        }
        return false;
    }
}
